package com.ruoyi.system.controller.web.bm;

import cn.hutool.core.collection.CollUtil;
import com.ruoyi.common.core.utils.CommonStreamUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.WebTableDataInfo;
import com.ruoyi.system.domain.BaseBasketballPlayer;
import com.ruoyi.system.domain.BaseContest;
import com.ruoyi.system.domain.bm.dto.CoachOrPlayerAuditDTO;
import com.ruoyi.system.domain.bm.dto.CoachOrPlayerListDTO;
import com.ruoyi.system.service.IBaseContestService;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;


/**
 * 报名系统后台
 * 
 */
@ApiOperation("报名系统后台")
@RestController
@RequestMapping("/web/bm")
public class BMWebController extends BaseController {
    @Resource
    private IBaseContestService baseContestService;
    /**
     * 查询报名系统教练or球员列表
     */
    @GetMapping("/coachOrPlayerList")
    @Operation(summary = "查询报名系统教练or球员列表", description = "查询报名系统教练or球员列表")
    public WebTableDataInfo coachOrPlayerList(CoachOrPlayerListDTO dto){
        List<BaseContest> baseContests = baseContestService.selectBaseContestList(new BaseContest());
        if (CollUtil.isEmpty(baseContests)){
            return getWebDataTable(new ArrayList<>());
        }
        dto.setContestIds(CommonStreamUtil.transList(baseContests, BaseContest::getId));
        startPage();
        return getWebDataTable(baseContestService.coachOrPlayerList(dto));
    }

    /**
     * 审核报名
     */
    @PostMapping("/coachOrPlayerAudit")
    @Operation(summary = "审核报名", description = "审核报名")
    public AjaxResult coachOrPlayerAudit(@RequestBody CoachOrPlayerAuditDTO param){
        return success(baseContestService.coachOrPlayerAudit(param));
    }
}

